
#include<vector>
#include<functional>



namespace A

{
    template<class T>
    class less {
    public:
        bool operator()(const T& x, const T& y) {
            return x < y;
        }
    };

    template<class T>
    class greater {
    public:
        bool operator()(const T& x, const T& y) {
            return x > y;
        }
    };


    template <class T, class Container = vector<T>, class Compare = less<T> >

    class priority_queue

    {

    public:
      
       // template <class InputIterator>

       // priority_queue(InputIterator first, InputIterator last);

        void adjustup(int child) {
            Compare comp;
            int parent = (child - 1) / 2;
            while (child>0) {
                
                if (comp(c[parent] ,c[child])) {
                    swap(c[parent], c[child]);
                    child = parent;
                    parent = (child - 1) / 2;
                }
                else {
                    break;
                }
            }
        }

        void adjustdown(int parent) {
            Compare comp;
            int child = parent * 2 + 1;
            while (child<c.size()) {
                if (child+1<c.size()&&comp(c[child] , c[child + 1])) {
                    child ++;
                }
                if (comp(c[parent], c[child])) {
                    swap(c[parent], c[child]);
                    parent=child;
                    child = parent * 2 + 1;
                }
                else {
                    break;
                }
            }
        }


        bool empty() const {
            return c.empty();
        }

        size_t size() const {
            return c.size();
        }

        const T& top() const {
            return c[0];
        }

        void push(const T& x) {
            c.push_back(x);
            adjustup(size()-1);

        }

        void pop() {
            swap(c[0], c[size() - 1]);
            c.pop_back();
            adjustdown(0);
        }


    private:

        Container c;


    };

};